export const getDate = () => {
    const date = new Date();
    const week= {
      0: '星期天',
      1: '星期一',
      2: '星期二',
      3: '星期三',
      4: '星期四',
      5: '星期五',
      6: '星期六'
     }
    let dateObj = {};
    
    dateObj.date = `${date.getFullYear()}/${(date.getMonth()+1) < 10 ? "0" + (date.getMonth() + 1) : date.getMonth()+1}/${date.getDate() < 10 ? "0" + date.getDate() : date.getDate()}/${week[date.getDay()]}`;
  
    let h1= date.getHours().toString().padStart(2, "0")
    let m1 = date.getMinutes().toString().padStart(2, "0")
    let s1 = date.getSeconds().toString().padStart(2,"0")
    dateObj.time = `${h1}:${m1}:${s1}`
    return dateObj
  }
  
  
  export const timeTemp = (x) => {
    let oldDate = new Date()
    // 十四天时间戳
    let dateItem = new Date(oldDate.getTime() - x * 24 * 60 * 60 * 1000);
    let year = dateItem.getFullYear();
    let month = (dateItem.getMonth() + 1).toString().padStart(2, '0');
    let day = dateItem.getDate().toString().padStart(2, "0")
    let h = dateItem.getHours().toString().padStart(2, "0")
    let m = dateItem.getMinutes().toString().padStart(2, "0")
    let s = dateItem.getSeconds().toString().padStart(2,"0")
  
    // 当前
    let date = new Date() ;
    let year1 = date.getFullYear();
    let month1 = (date.getMonth() + 1).toString().padStart(2, '0');
    let day1 = date.getDate().toString().padStart(2, "0")
    let h1= date.getHours().toString().padStart(2, "0")
    let m1 = date.getMinutes().toString().padStart(2, "0")
    let s1 = date.getSeconds().toString().padStart(2,"0")
    
    return  [`${year}-${month}-${day}` , `${year}-${month}-${day} ${h}:${m}:${s}` ,`${year1}-${month1}-${day1} ${h1}:${m1}:${s1}` ]
  }
  export const formDateByDate = (date) => {
    // 十四天时间戳
    let dateItem = new Date(date);
    let year = dateItem.getFullYear();
    let month = (dateItem.getMonth() + 1).toString().padStart(2, '0');
    let day = dateItem.getDate().toString().padStart(2, "0")
    let h = dateItem.getHours().toString().padStart(2, "0")
    let m = dateItem.getMinutes().toString().padStart(2, "0")
    let s = dateItem.getSeconds().toString().padStart(2,"0")
  
    
    return   `${year}-${month}-${day} ${h}:${m}:${s}` 
  }
  